package Messages;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import Server.SQLConnection;
import ocsf.server.ConnectionToClient;


public class MessageLoadStep {

	private ConnectionToClient client ;
	private ArrayList<Object> str ;
	
public MessageLoadStep(ArrayList<Object> msg, ConnectionToClient client) {
		
		this.client= client ;
		this.str= msg; 		
		
	}

public void Load(String StepId,String ScenarioName) throws SQLException, IOException {
	SQLConnection sc = new SQLConnection();
	
	java.sql.PreparedStatement ScenarioTemp = sc.getConnection().prepareStatement("SELECT t.`Teststep`,t.`Expected`,t.`Actual`,t.`Comment` FROM hts."+ScenarioName+" t where idScenario= '"+StepId+"';");

	ResultSet LoadRs= ScenarioTemp.executeQuery();
	
	ArrayList<Object> Run =new ArrayList<Object>();
	Run.add("LoadStep");
	Run.add(ScenarioName);
	Run.add(StepId);
	while (LoadRs.next())
	{
	
		Run.add(LoadRs.getString(1));  	//teststep
		Run.add(LoadRs.getString(2)); 	//exp 
		Run.add(LoadRs.getString(3));	//actu 
		//Run.add(LoadRs.getString(6));	//status
		Run.add(LoadRs.getString(4)); //comment

	}
	LoadRs.close();
	ScenarioTemp.close();

	client.sendToClient(Run);
}

}
